<template>
  <div class="all">
    <div class="top">
      <el-row>
        <el-form ref="form" inline label-position="left">
          <el-col :span="3">
            <el-form-item :label="$t('app.status')">
              <SelfSelect v-model="query.status" :show-list="bookStatus" />
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item :label="$t('app.stock.appearBook.source')">
              <SelfSelect v-model="query.from_type" :show-list="bookType" />
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item :label="$t('app.stock.appearBook.workshop')">
              <Selects v-model="data.workshop_id" action="factoryList" :query="{ category: 2 }" />
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item :label="$t('app.stock.appearBook.store')">
              <Selects v-model="data.store_id" action="storeList" />
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item :label="$t('app.stock.appearBook.getTime')">
              <el-date-picker v-model="query.get_time" type="datetimerange" range-separator="-" start-placeholder="" end-placeholder="" />
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item :label="$t('app.stock.appearBook.verifyAdmin')">
              <Selects v-model="query.verify_admin_id" action="adminList" />
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item>
              <el-button style="margin-top: 38%" icon="el-icon-search" type="primary" @click="index">查找</el-button>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <el-row class="btns">
        <el-button type="primary" icon="el-icon-refresh" @click="refresh">{{ $t('button.refresh') }}</el-button>
      </el-row>
      <span class="total">{{ $t('app.count') }}：{{ total }}</span>
    </div>
    <div class="main">
      <div class="table">
        <el-table ref="multipleTable" v-loading="loading" border tooltip-effect="dark" width="100%" stripe :data="dataList" @selection-change="handleSelectionChange">
          <el-table-column :label="$t('app.Num')" type="index" align="center" width="50" />
          <el-table-column type="selection" align="center" width="55" />
          <el-table-column prop="parts_name" label="备件-编号" align="center" width="220" />
          <el-table-column prop="number" :label="$t('app.stock.appearBook.number')" align="center" />
          <el-table-column prop="status" :label="$t('app.status')" align="center" width="120">
            <template scope="{ row }">
              <div v-html="row.status" />
            </template>
          </el-table-column>
          <el-table-column prop="parts_spec" label="规格型号" align="center" width="180" />
          <el-table-column prop="parts_brand" label="品牌" align="center" />
          <el-table-column prop="parts_provider" label="供应商" align="center" />
          <el-table-column prop="parts_unit" label="单位" align="center" />
          <el-table-column prop="parts_price" label="单价" align="center" />
          <el-table-column prop="total_price" label="合计" align="center" />
          <el-table-column prop="store" :label="$t('app.stock.appearBook.store')" align="center" />
          <el-table-column prop="workshop" :label="$t('app.stock.appearBook.workshop')" align="center" width="160" />
          <el-table-column prop="type" label="来源" align="center" />
          <el-table-column prop="create_time" :label="$t('app.stock.appearBook.applyTime')" align="center" width="160" />
          <el-table-column prop="get_time" :label="$t('app.stock.appearBook.getTime')" align="center" width="160" />
          <el-table-column prop="apply_admin" :label="$t('app.stock.appearBook.applyAdmin')" align="center" />
          <el-table-column prop="appear_order" :label="$t('app.stock.appearBook.appearOrder')" align="center" width="300" />
        </el-table>
        <el-pagination class="page" background :page-size="query.limit" align="center" layout="total,prev,pager,next,jumper" :total="total" :current-page.sync="query.page" @current-change="index" @size-change="index" />
      </div>
    </div>
  </div>
</template>

<script>
import API from '@/api/stock/appear'
import Selects from '@/components/select-search'
import { bookStatus, bookType } from '@/utils/option'
import SelfSelect from '@/components/select-o'
export default {
  components: {
    SelfSelect,
    Selects
  },
  inject: ['goUrl', 'orderStatus', 'reload'],
  data() {
    return {
      data: {
      },
      dataList: [],
      total: 0,
      loading: true,
      query: {
        limit: 15,
        page: 1,
        kind: 1
      },
      isRouterAlive: true,
      bookStatus,
      bookType,
      disabled: true,
      multipleSelection: []
    }
  },
  created() {
    this.index()
  },
  methods: {
    index() {
      this.loading = true
      API.book(this.query).then(res => {
        this.dataList = res.data.data
        this.total = res.data.total
      }).finally(() => {
        this.loading = false
      })
    },
    refresh() {
      this.reload()
    },
    orderFormatter(row) {
      return this.orderStatus(row)
    },
    handleSelectionChange(val) {
      this.multipleSelection = val
    }
  }
}
</script>

<style scoped>

</style>
